<link rel="stylesheet" href="https://file.viplgw.cn/ui/thinku-ielts-new/css/evaluation/notice.css">
<script src="/cn/js/jquery-1.12.2.min.js"></script>
<div class="head">
    <div class="container">
        <img>
    </div>
</div>
<div class="container">
    <p class="evaluation_name">申友雅思<?php echo $paper['name']?>测评试题</p>
    <p class="section_title">一、测评说明</p>
    <p class="section_des">根据您的基础情况，选择适合您的测评套题，完成测试将自动显示测评分数报告及详细复习计划！</p>
    <p class="section_title">二、测评内容</p>
    <p class="section_des">可根据需求选择板块进行测试，也可全选；可提前交卷，时间结束自动交卷，无法继续作答，请注意把握时间。</p>
    <ul class="evaluation_table">
        <li>
            <p>类别</p>
            <p>限时</p>
        </li>
        <?php foreach ($subject as $k => $v) { ?>
            <li>
                <p><?php echo $v['name'] ?></p>
                <p><?php echo $v['time'] ?>min</p>
            </li>
        <?php } ?>

    </ul>

    <p class="red_text">请先选择测试试题，可全选</p>
    <ul class="options">

        <?php foreach ($subject as $k => $v) { ?>
            <li><input type="checkbox" name="subject" value="<?php echo $v['id'] ?>"
                ><?php echo $v['name'] ?></li>
        <?php } ?>

    </ul>
    <p class="section_title">三、注意事项</p>
    <p class="section_des">1、做题前，请仔细阅读答题说明，确保设备正常使用；<br>
        2、测评成绩将保留五天，超过即需更新模考；<br>
        3、在考试过程中，请不要关闭浏览器、关机或者中断网络，否则可能会导致部分记录无效；<br>
        4、已完成/中断的模考,请到测评首页"测评记录"中查看记录及结果。</p>
    <p class="start_btn">
        <a href="javascript:void(0)" onclick="choiceSubject()">进入测评</a>
    </p>
    <input id="paperid" value="<?php echo isset($_GET['paperId']) ? $_GET['paperId'] : 1 ?>" type="hidden">
</div>
<script>
    function choiceSubject() {
        var ids = document.getElementsByName("subject");
        var str = [];
        for (i = 0; i < ids.length; i++) {
            if (ids[i].checked) {
                str.push(ids[i].value);
            }
        }
        console.log('str', str)
        $.ajax({
            type: 'POST',
            url: "/cn/evaluation/choice-subject",
            dataType: "json",
            data: {
                subjectId: str.join(','),
                cateId: $('#paperid').val()
            },
            success: function (res) {
                if (res.code == 1) {
                    console.log('res.data.subjectId.length', res.data.subjectId.length);
                    if (str.length == 0) {
                        alert('请选择测试试题')
                    } else {
                         window.location.href = "/evaluation/question.html?subjectId=" + res.data.subjectId[0] + '&pubId=' + res.data.pubId
                    }

                } else {
                    alert(res.data)
                }
            }
        })
    }
</script>
